<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>购物车布局</title>
  <link href="css/cart.css" rel="stylesheet">
</head>
<body>
  <div id="app" class="container">

    <!-- 空购物车界面 -->
    <div class="empty-cart-message" v-if="cartItems.length === 0">
    <div class="empty-cart-image"></div>
      您的购物车空空如也
      去购物
    </div>

    <div class="cart" ref="cart">
      <h1>科泰淘购物车</h1>
      <div class="clearfix">
  <a href="javascript:void(0)" class="delete-selected" @click.prevent="deleteSelectedItems">删除选中</a>   
  <a href="#" class="clear-cart" @click.prevent="clearCart">清空购物车</a>
      </div>
      <div class="cart-item" v-for="(item, index) in cartItems" :key="index">
        <div class="cart-item-details">
          <input type="checkbox" class="cart-item-checkbox" v-model="item.checked" @change="toggleItemCheck">
          <img :src="item.image" :alt="item.name">
          <div class="cart-item-name-sku">
            <div class="cart-item-name">{{ item.name }}</div>
            <div class="cart-item-sku">{{ item.sku }}</div>
          </div>
        </div>
        <div class="cart-item-quantity-price">
          <div class="cart-item-quantity">
            <button class="quantity-btn minus-btn" @click.prevent="decrementQuantity(item)">-</button>
            <input type="text" :value="item.quantity" @input="updateQuantity($event, item)" class="quantity" readonly>
            <button class="quantity-btn plus-btn" @click.prevent="incrementQuantity(item)">+</button>
          </div>
          <div class="cart-item-price">￥{{ item.price.toFixed(2) }}</div>
        </div>
      </div>

      <div class="total-price-container">
        <div class="total-count" ref="countValue">已选 <span class="count-value">{{ selectedCount }}</span> 件</div>
        <div class="total-price" ref="totalPrice">总计：￥{{ totalPrice.toFixed(2) }}</div>
      </div>

      <div class="clearfix">
        <div class="select-all-container">
          <input type="checkbox" id="select-all-checkbox" class="cart-item-checkbox" v-model="isSelectAllChecked" @change="toggleSelectAllCheck">
          <label for="select-all-checkbox">全选</label>
        </div>
        <a href="javascript:void(0)" class="go-checkout" @click.prevent="checkEmptyCart">去结算</a>
      </div>
    </div>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <script src="js/cart-vue.js"></script>
</body>
</html>